How can I convert a series of images to a PDF from the command line on linux?

Table of Contents

How can I convert a series of images to a PDF from the command line on linux?

Nhu cầu

Tình hình là hồi trước mình có viết cái tool crawl truyện tranh về cho cháu mình đọc. Tuy nhiên mình crawl dạng ảnh.

image

Nay có nhu cầu đọc truyện thì nó hơi bất tiện. Do vậy mình muốn tạo nó thành file pdf để upload vô Google Books để dễ quản lý, dễ đọc giống như vầy

image

Hiện trạng

Mình đã có bộ truyện dạng ảnh trên Google Drive Google Books có chức năng upload trực tiếp từ Google Drive

=> Mình muốn chạy tool lưu trực tiếp trên Google Drive, đỡ phải mắc công download hết đống ảnh về, tạo pdf rồi lại phải upload ngược trở lại vô Google Books (Mạng mẽo nhà mình chán lắm :') )

Do vậy mình quyết định dùng Google Colab để viết tool, connect vô Google Drive, chạy trực tiếp trên đó, lưu vô Google Drive

Thực hiện

!pip install img2pdf
# hoặc
!apt install img2pdf

# Tạo pdf
!img2pdf $(find . -iname '*.png' | sort -V) -o /content/ch1.pdf

image

Note book

https://colab.research.google.com/drive/1O6ltnTxxxYfJg0t4FJmH55rViQ0B6dUk#scrollTo=Oqb4iPtR0iNs

Tham khảo

https://stackoverflow.com/questions/8955425/how-can-i-convert-a-series-of-images-to-a-pdf-from-the-command-line-on-linux

Leave a Reply

Your email address will not be published. Required fields are marked *